-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
USE [WarehouseManagement]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		TuyenVD
-- Create date: 3/16/2011
-- Description:	This stored procedure use to get a Role record
-- =============================================
ALTER PROCEDURE GetSingleRole 
	-- Add the parameters for the stored procedure here
(
@RoleID int = 0
)	 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT 
			r.[RoleID]
			, r.[RoleName]
			, r.[RoleCode]
			, r.IsDelete
			, r.[BriefDescription]
			, r.[FullDescription]
	FROM 
			[Role] r
	Where 
			r.[RoleID] = @RoleID AND r.[IsDelete] = 0

	
	SELECT 
			a.[AuthorizationID]
			, a.[Description]
	FROM
			[Authorization] a
	
	INNER JOIN
			[DefaultRoleAuthorization] dra
	ON
			dra.[AuthorizationID] = a.[AuthorizationID] AND dra.[RoleID] = @RoleID
END
GO

/*
USE WarehouseManagement
GO

EXEC GetSingleRole 1
*/